package model

import (
	"gorm.io/gorm"
	__ "video-srv/basic/proto/rpc"
)

type Member struct {
	gorm.Model
	Title      string `gorm:"type:varchar(30)" json:"title"`
	Duration   int    `gorm:"type:int" json:"duration"`
	Price      int    `gorm:"type:int" json:"price"`
	ExpireTime int    `gorm:"type:int" json:"expireTime"`
}

func (m *Member) IsMember(db *gorm.DB, id int) error {
	return db.Where("id = ?", id).First(&m).Error
}

func (m *Member) GetMemberList(db *gorm.DB) (list []*__.MemberList, err error) {
	err = db.Model(&m).
		Select("title,duration,price,expire_time").
		Find(&list).Error
	return
}
